package com.aphrodite.io.sip.transaction;

import com.aphrodite.io.sip.message.Message;
import com.aphrodite.io.sip.message.SipMethods;
import com.aphrodite.io.sip.provider.SipProvider;

/**
 * InviteTransactionServerAccepter listens for new incoming invite transaction
 * requests.
 */
public class InviteTransactionServerAccepter extends TransactionServerAccepter {
	/**
	 * InviteTransactionServerAccepterListener that captures new invite
	 * transactions.
	 */
	InviteTransactionServerAccepterListener listener;

	/**
	 * Creates a new InviteTransactionServerAccepter of type <i>method</i>, and
	 * starts listening for incoming trasaction requests.
	 */
	public InviteTransactionServerAccepter(SipProvider sip_provider, InviteTransactionServerAccepterListener listener) {
		super(sip_provider, SipMethods.INVITE, null);
		this.listener = listener;
	}

	/** Method derived from interface SipListener. */
	public void onReceivedMessage(SipProvider provider, Message msg) {
		if (listener != null)
			listener.onNewInviteTransactionServer(this, new InviteTransactionServer(sip_provider, msg, listener));
	}

}
